package arandomPractice;

import com.sun.javafx.image.IntPixelGetter;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;

public class Class162 {
    public int findPeakElement(int[] nums) {
        int ans=0;
       Deque<Integer> stack = new LinkedList<Integer>();
       stack.push(0);
        for (int i = 1; i <nums.length ; i++) {
            while (!stack.isEmpty()){
                if (nums[i]>nums[stack.peek()]){
                    stack.push(i);
                }else {
                    ans=stack.peek();
                    break;

                }

            }
        }


       return  ans;
    }
}
